package com.kaisheng.service;

import com.kaisheng.dao.DocumentDao;
import com.kaisheng.entity.Document;
import com.kaisheng.util.PKUtil;
import com.kaisheng.util.Page;
import com.kaisheng.util.TimeUtil;

public class DocumentService {
	DocumentDao dd = new DocumentDao();
	public Page<Document> findByProjectId(String project_id,int pageNum) {
		
		Page<Document> page =  new Page<Document>(6,dd.getCount(),pageNum);
		
		return dd.findByProjectId(project_id,page);
	}
	
	public Document findByDocumentId(String document_id) {
		return dd.findByDocumentId(document_id);
	}
	public boolean save(String title, String content, String user_id,
			String project_id) {
		Document document = new Document();
		document.setId(PKUtil.getId());
		document.setTitle(title);
		document.setContent(content);
		document.setCreatetime(TimeUtil.getTime());
		document.setProject_id(project_id);
		document.setUser_id(user_id);
		return dd.save(document);
	}

	public void update(String title, String content, String document_id) {
		dd.update(title,content,document_id);
		
	}

	public void del(String document_id) {
		dd.del(document_id);
		
	}
	

}
